package org.jeecg.modules.api;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.ServiceNameConstants;
import org.jeecg.modules.api.DTO.AddEmissionByCarbonCheckDTO;
import org.jeecg.modules.api.DTO.EmissionFactorQueryDTO;
import org.jeecg.modules.api.DTO.PrivateFactorQueryDTO;
import org.jeecg.modules.api.VO.EmissionFactorDescribeVO;
import org.jeecg.modules.api.VO.EmissionFactorVO;
import org.jeecg.modules.api.entity.CyEmissionFactor;
import org.jeecg.modules.api.entity.CyEmissionUnit;
import org.jeecg.modules.api.entity.CyGasStore;
import org.jeecg.modules.api.falback.CyEmissionFactorFallback;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author mjh
 * Date: 2024/11/19 18:54
 */
@Component
@FeignClient(contextId = "cyEmissionFactorApi", value = ServiceNameConstants.EMISSION_SERVICE, path = "/emission/factor/cyEmissionFactor/api", fallback = CyEmissionFactorFallback.class)
@ConditionalOnMissingClass("org.jeecg.modules.factor.controller.CyEmissionFactorApiController")
public interface CyEmissionFactorApi {

    /**
     * 根据id查询碳排因子详情
     * @param id 碳排因子id
     */
    @GetMapping(value = "/listInfo")
    Result<EmissionFactorVO> listInfo(@RequestParam(name="id",required=true)String id);

    /**
     * 批量查询碳排因子主体信息
     * @param idList 碳排因子id集合
     */
    @GetMapping(value = "/batchGetFactorInfo")
    public Result<List<CyEmissionFactor>> batchGetFactorInfo(@RequestParam(name="idList",required=true) List<String> idList);


    /**
     * 根据id集合批量查询碳排因子详情
     * @param idList 碳排因子id集合
     */
    @GetMapping(value = "/batchListInfo")
    Result<List<EmissionFactorVO>> batchListInfo(@RequestParam(name="idList",required=true) List<String> idList);

    /**
     * 产品碳足迹和组织碳盘查中使用的分页列表查询
     *
     * @param privateFactorQueryDTO 分页列表查询条件dto
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/privateList")
    Result<?> privateQueryPageList(PrivateFactorQueryDTO privateFactorQueryDTO,
                                          @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                          @RequestParam(name="pageSize", defaultValue="10") Integer pageSize);

    /**
     * 批量查询碳排因子使用说明对象
     * @param idList 碳排因子id集合
     */
    @GetMapping(value = "/describeList")
    Result<List<EmissionFactorDescribeVO>> describeList(@RequestParam(name="idList",required=true) List<String> idList);

    /**
     * 碳排因子收藏
     * @param emissionFactorId 碳排因子id
     */
    @GetMapping(value = "/emissionCollect")
    Result<String> emissionCollect(@RequestParam(name="id",required=true) String emissionFactorId);


    /**
     * 组织碳盘查中的手动添加碳排因子
     * @param addEmissionByCarbonCheckDTO 手动新增碳排因子对象
     */
    @PostMapping(value = "/addEmissionByCarbonCheck")
    Result<String> addEmissionByCarbonCheck(@RequestBody AddEmissionByCarbonCheckDTO addEmissionByCarbonCheckDTO);


    /**
     * 查询所有单位分组
     */
    @GetMapping(value = "/getAllUnitGroup")
     Result<?> getAllUnitGroup();


    /**
     * 返回树形产品单位(先查询所有单位分组，再根据单位分组id查询出分组下的所有单位)
     */
    @GetMapping(value = "/getUnitTree")
    Result<Map<String, List<CyEmissionUnit>>> getUnitTree();


    /**
     * 根据碳排因子idList获取到所有碳排因子中的所有气体配比信息
     *  @param EmissionFactorIdList  碳排因子id集合
     */
    @GetMapping(value = "/batchGetGasRatio")
    Result<?> batchGetGasRatio(@RequestParam(name="idList",required=true) List<String> EmissionFactorIdList);

    /**
     * 碳排因子收藏分页列表查询
     *
     * @param emissionFactorQueryDTO 碳排因子分页列表查询对象
     * @param pageNo
     * @param pageSize
     * @param req
     */
    @GetMapping(value = "/getCollectList")
    Result<?> getCollectList(EmissionFactorQueryDTO emissionFactorQueryDTO,
                                    @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                    @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                    HttpServletRequest req);

    /**
     * 根据原单位和目标单位查询出转换比率
     * @param sourceUnit  原单位
     * @param targetUnit 目标单位
     */
    @GetMapping(value = "/getConvertValue")
     Result<Double> getConvertValue(@RequestParam(name="sourceUnit", required = true) String sourceUnit,
                                     @RequestParam(name="targetUnit", required = true) String targetUnit);

    /**
     * 获取所有温室气体名称
     * @return
     */
    @GetMapping(value = "/batchGetGasStore")
    Result<List<CyGasStore>> batchGetGasStore();
}
